08. The src Directory Additional Files
The src Directory Additional Files
You will not need to write code in the following files:
-
model.handmodel.cpp -
render.handrender.cpp -
route_model.handroute_model.cpp
The videos below are included to give you a better understanding of the code in those files. We will not cover
model.cpp
or
render.cpp
, as these are beyond the scope of the first course in this Nanodegree. However, we will walk through the header files for these two files, which will provide an overview of the corresponding classes and methods.
model.h
Model H Take 2
The
model.h
and
model.cpp
files come from the IO2D example code. We provide an overview of only the
model.h
file, as the method implementations in
model.cpp
file are beyond the scope of the course.
These files are used to define the data structures and methods that read in and store OSM data. OSM data is stored in a
Model
class which contains nested structs for Nodes, Ways, Roads, and other OSM objects. Have a look at the video above for an overview of the code in the header file.
route_model.h and route_model.cpp
Rm Full
These files contain classes which are used to extend the
Model
and
Node
data structures from
model.h
and
model.cpp
using class inheritance. Remember that inheritance in this case will allow you to use all of the
public
methods and attributes of the
Model
class and
Node
struct in the derived
RouteModel
and
RouteModel::Node
classes.
The reason for extending the existing
Model
class and
Node
struct is to include additional methods and variables which are useful for A* search. In particular, the new
RouteModel::Node
class now allows nodes to store the following:
- the h-value,
- the g-value,
- a "visited" flag,
- a vector of pointers to neighboring nodes.
In addition, there are now methods for
- finding neighboring Node objects of a Node,
- getting the distance to other nodes,
- finding the closest node to a given (x, y) coordinate pair.
render.h
Render H
The
render.h
and
render.cpp
files come from the IO2D example code. These take map data that is stored in a
Model
object and render that data as a map. We have modified these files slightly to include three extra methods which render the start point, end point, and path from the A* search. You won't need to work with these files directly, but you can watch the video above for a brief overview of the header file code.